<template>
  <div id="radio_group">
    <div class="title" v-if="title">{{ title }}</div>
    <div class="radio_wrap">
      <!-- 日周月 榜单 -->
      <div
        :class="{
          radio_item: true,
          radio_item_blue: radio_value == item && isSearch != '1',
          radio_item_blue_search: radio_value == item && isSearch == '1'
        }"
        v-for="(item, index) in radio_values"
        :key="'radio_group' + index"
        @click="
          now_radio_value = item;
          $emit('returnBack', now_radio_value);
        "
      >
        {{ item }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "radio_group",
  data() {
    return {
      now_radio_value: this.radio_value
    };
  },
  model: {
    prop: "radio_value",
    event: "returnBack"
  },
  props: ["radio_values", "radio_value", "title", "isSearch"],
  created: function() {
    this.$watch("radio_value", function(newValue, oldValue) {
      this.now_radio_value = this.radio_value;
    });
  }
};
</script>
<style scoped lang="less">
#radio_group {
  display: flex;
  margin-bottom: 5px;
  .title {
    font-size: 14px;
    line-height: 32px;
    white-space: nowrap;
    color: #888888;
    margin-right: 48px;
  }
  .radio_item {
    cursor: pointer;
    outline: none;
    height: 32px;
    border-radius: 4px;
    font-size: 14px;
    color: #555555;
    line-height: 32px;
    margin-bottom: 7px;
    padding: 0 16px;
    margin-right: 8px;
    box-sizing: border-box;
  }
  .radio_item:hover {
    color: #ff924b;
  }
  .radio_item_blue {
    color: #fff !important;
    background-color: #fd7f2c !important;
  }
  .radio_item_blue_search {
    color: #fd7f2c !important;
    background-color: #fff1e8 !important;
  }
  .radio_item:first-child {
    margin-left: 0;
  }
  .radio_wrap {
    display: flex;
    flex-wrap: wrap;
  }
}
</style>
